var getNum = (n) => {
    let promise = new Promise((resolve, reject) => {
        setTimeout(() => reject(n + 10), 1000);
    });
    return promise;
}

getNum(10).then((result) => {
    console.log("resolve 0", result)
    return result;
}, (result) => {
    console.log("reject 0", result)
    return result;
})
.then((result) => {
    console.log("resolve 1", result)
    return getNum(result);
}, (result) => {    
    console.log("reject 1", result)
    return getNum(result);
})
.then((result) => {
    console.log("resolve 2", result);
    throw new Error("test catch 2");
}, (result) => {
    console.log("reject 2", result);
    throw new Error("test catch 2");
})
.catch(error => console.log(error));